﻿using System;
using E_Commerce.Domain.Entities;
using E_Commerce.Domain.Interfaces;//引用
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using AutoMapper;//引用AutoMapper
using E_Commerce.Application.Dto;

namespace E_Commerce.Application
{
   public class ProductCategoryService:IproductCategoryService
    {
        /// <summary>
        /// 依赖注入
        /// </summary>
        private IProductCategoryRepository _productCategoryRepository;
        private IMapper _mapper;
        public ProductCategoryService(IProductCategoryRepository productCategoryRepository, IMapper mapper)
        {
            _productCategoryRepository = productCategoryRepository;
            _mapper = mapper;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public async Task<int> AddCateAsync(ProductCategory p)
        {
            return await _productCategoryRepository.AddCateAsync(p);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<int> DeleCateAsync(int id)
        {
            return await _productCategoryRepository.DeleCateAsync(id);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<ProductCategory> FillCateAsync(int id)
        {
            return await _productCategoryRepository.FillCateAsync(id);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        public List<ProductCategory> GetProductCategories()
        {
            return _productCategoryRepository.GetProductCategories();
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public async Task<int> UptCateAsync(ProductCategory p)
        {
            return await _productCategoryRepository.UptCateAsync(p);
        }
    }
}
